package team.shuguoyiyou.authcode.authcode.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import team.shuguoyiyou.authcode.authcode.properties.AjCaptchaProperties;
import team.shuguoyiyou.authcode.authcode.service.CaptchaCacheService;
import team.shuguoyiyou.authcode.authcode.service.impl.CaptchaServiceFactory;

/**
 * Created by ZengJian on 2021/2/3 0003 上午 9:22
 * 存储策略自动配置.
 */
@Configuration
public class AjCaptchaStorageAutoConfiguration {

    @Bean(name = "AjCaptchaCacheService")
    public CaptchaCacheService captchaCacheService(AjCaptchaProperties ajCaptchaProperties) {
        // 缓存类型redis/local/....
        return CaptchaServiceFactory.getCache(ajCaptchaProperties.getCacheType().name());
    }
}
